package com.warmer.web.service.impl;

import com.warmer.web.dal.IKnowledgegraphRepository;
import com.warmer.web.service.IKnowledgegraphService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class KnowledgegraphService implements IKnowledgegraphService {

	@Autowired
	private IKnowledgegraphRepository knowledgegraphRepository;
	@Override
	public List<Map<String, Object>> getDomainList(String domainname,String createUser) {
		List<Map<String,Object>> list = knowledgegraphRepository.getDomainList(domainname,createUser);
		return list;
	}

	@Override
	public void saveDomain(Map<String, Object> map) {
		knowledgegraphRepository.saveDomain(map);		
	}
	@Override
	public void quickCreateDomain(String domain) {
		Map<String, Object> maps = new HashMap<String, Object>();
		maps.put("name", domain);
		maps.put("nodeCount", 0);
		maps.put("shipCount", 0);
		maps.put("status", 1);
		maps.put("createUser", "tc");
		knowledgegraphRepository.saveDomain(maps);
	}

	@Override
	public void updateDomain(Map<String, Object> map) {
		knowledgegraphRepository.updateDomain(map);
	}

	@Override
	public void deleteDomain(Integer id) {
		knowledgegraphRepository.deleteDomain(id);
	}

	@Override
	public List<Map<String, Object>> getDomainByName(String domainname) {
		return knowledgegraphRepository.getDomainByName(domainname);
	}

	@Override
	public List<Map<String, Object>> getDomains() {
		return knowledgegraphRepository.getDomains();
	}

	@Override
	public List<Map<String, Object>> getRecommendDomainList() {
		return knowledgegraphRepository.getRecommendDomainList();
	}

	@Override
	public List<Map<String, Object>> getDomainById(Integer domainId) {
		return knowledgegraphRepository.getDomainById(domainId);
	}
	
	@Override
	public void saveNodeImage(List<Map<String, Object>> mapList) {
		knowledgegraphRepository.saveNodeImage(mapList);
	}

    @Override
    public void saveNodeContent(Map<String, Object> map) {
        knowledgegraphRepository.saveNodeContent(map);
    }

    @Override
    public void updateNodeContent(Map<String, Object> map) {
        knowledgegraphRepository.updateNodeContent(map);
    }

    @Override
	public List<Map<String, Object>> getNodeImageList(Integer domainId, Integer nodeId) {
		return knowledgegraphRepository.getNodeImageList(domainId,nodeId);
	}

    @Override
    public List<Map<String, Object>> getNodeContent(Integer domainId, Integer nodeId) {
        return knowledgegraphRepository.getNodeContent(domainId,nodeId);
    }

    @Override
    public void deleteNodeImage(Integer domainId, Integer nodeId) {
         knowledgegraphRepository.deleteNodeImage(domainId,nodeId);
    }

}
